<template>
  <CardVue height="2rem" title="风险处置" style="margin-bottom: 0.3rem">
    <div class="layout">
      <div class="layout-l">
        <div class="layout-l-img">
          <img src="@/assets/imgs/largeScreen/icon/a1.png" alt="" />
        </div>
        <div class="layout-l-c">
          <div class="layout-l-c-item risk1">
            <div class="layout-l-c-item-title">未处置风险</div>
            <div class="layout-l-c-item-num">{{ info.v4.three }}</div>
          </div>
          <div class="layout-l-c-item risk2">
            <div class="layout-l-c-item-title">已处置风险</div>
            <div class="layout-l-c-item-num">{{ info.v4.two }}</div>
          </div>
          <div class="layout-l-c-item risk3">
            <div class="layout-l-c-item-title">应处置风险</div>
            <div class="layout-l-c-item-num">{{ info.v4.one }}</div>
          </div>
        </div>
      </div>
      <div class="layout-r">
        <div
          class="layout-r-item"
          @click="open('应处置社会组织', { state: 0 })"
        >
          <div class="layout-r-item-title">
            应处置社会组织 <span>{{ info.v5.one }}</span>
          </div>
          <div class="layout-r-item-line"></div>
        </div>
        <div
          class="layout-r-item"
          @click="open('已处置社会组织', { state: 2 })"
        >
          <div class="layout-r-item-title">
            已处置社会组织 <span>{{ info.v5.two }}</span>
          </div>
          <div
            class="layout-r-item-line"
            :style="{ width: `${(info.v5.two / info.v5.one) * 100}%` }"
          ></div>
        </div>
        <div
          class="layout-r-item"
          @click="open('未处置社会组织', { state: 1 })"
        >
          <div class="layout-r-item-title">
            未处置社会组织 <span>{{ info.v5.three }}</span>
          </div>
          <div
            class="layout-r-item-line"
            :style="{ width: `${(info.v5.three / info.v5.one) * 100}%` }"
          ></div>
        </div>
      </div>
    </div>
  </CardVue>
  <PopupVue ref="PopupVueRef" />
</template>
<script setup lang="ts">
import CardVue from '@/views/largeScreen/components/card/card.vue'
import { dpcont } from '@/api/spotCheck/spotCheck'
import { onMounted, ref } from 'vue'
import PopupVue from './popup.vue'

interface Info {
  v1: {
    alls: number
    logout: number
    back: number
    uses: number
    st: number
    mf: number
  }
  v2: {
    one: number
    two: number
    three: number
  }
  v3: {
    one: number
    two: number
    three: number
  }
  v4: {
    one: number
    two: number
    three: number
  }
  v5: {
    one: number
    two: number
    three: number
  }
  v6: {
    one: number
    two: number
    three: number
  }
  v7: {
    one: number
    two: number
    three: number
  }
}

const info = ref<Info>({
  v1: {
    alls: 0,
    logout: 0,
    back: 0,
    uses: 0,
    st: 0,
    mf: 0
  },
  v2: {
    one: 0,
    two: 0,
    three: 0
  },
  v3: {
    one: 0,
    two: 0,
    three: 0
  },
  v4: {
    one: 0,
    two: 0,
    three: 0
  },
  v5: {
    one: 0,
    two: 0,
    three: 0
  },
  v6: {
    one: 0,
    two: 0,
    three: 0
  },
  v7: {
    one: 0,
    two: 0,
    three: 0
  }
})

onMounted(() => {
  dpcont().then((res) => {
    info.value = res.data
  })
})

const PopupVueRef = ref<InstanceType<typeof PopupVue> | null>(null)

const open = (title, params) => {
  console.log('点击了')
  PopupVueRef.value?.show({ title, query: params })
}
</script>

<style scoped lang="scss">
.layout {
  width: 100%;
  height: 100%;
  display: flex;
  .layout-l {
    width: 2rem;
    position: relative;
    transform: translateY(0.2rem);
    .layout-l-img {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      img {
        width: 1.2rem;
        height: 0.8rem;
        transform: translateX(-0.2rem);
      }
    }
    .layout-l-c {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      .layout-l-c-item {
        width: fit-content;
        .layout-l-c-item-title {
          font-size: 0.12rem;
          color: #44cfb9;
          margin-bottom: 0.01rem;
          text-align: center;
        }
        .layout-l-c-item-num {
          font-size: 0.12rem;
          color: #44cfb9;
          font-weight: bold;
          text-align: center;
        }
      }
      .risk1 {
        position: absolute;
        left: 0.5rem;
        top: 0.1rem;
      }
      .risk2 {
        position: absolute;
        left: -0.2rem;
        top: 0.8rem;
      }
      .risk3 {
        position: absolute;
        right: 0.2rem;
        top: 0.8rem;
      }
    }
  }
  .layout-r {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    .layout-r-item {
      width: 100%;
      margin-bottom: 0.1rem;
      .layout-r-item-title {
        font-size: 0.12rem;
        color: #fff;
        margin-bottom: 0.05rem;
      }
      .layout-r-item-line {
        width: 100%;
        height: 0.2rem;
        background-color: #44cfb9;
      }
    }
  }
}
</style>
